<?php
/**
 * Created by PhpStorm.
 * User: 共赢岛
 * Date: 2024/1/27
 * Time: 9:53
 */

namespace App\Http\Controllers\API;

use App\Models\SmsLog;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class SmsController extends Controller
{
    public function sendSms(Request $request)
    {
        $data = SmsLog::sendVerifyCode($request->get('phone'));

        if ($data['code'] == 200) {
            return $this->success('短信发送成功！');
        } else {
            return $this->failure($data['message']);
        }
    }

    public function verifySms(Request $request)
    {
        $param = $request->all();
        $data = SmsLog::checkCode($param['phone'], $param['code']);

        if ($data['code'] == 200) {
            return $this->success('验证成功！');
        } else {
            return $this->failure($data['message']);
        }
    }
}